import { defineStore } from 'pinia'
import { ref } from 'vue'

// 用户相关 定义 Store
export const useMemberStore = defineStore(
  'member',
  () => {
    const controls_list = [
      {
        img: 'firm.png',
        id: 'firm',
        color: '#CED8FE',
        theme: 'InventoryManagement',
        path: '/pages/index/firm/firm',
        naem: '企业信息',
      },
      {
        naem: '设施信息',
        img: 'facility.png',
        id: 'facility',
        color: '#FEE8B7',
        theme: 'InventoryManagement',
        path: '/pages/index/facility/facility',
      },
      {
        naem: '废物信息',
        img: 'trash.png',
        id: 'trash',
        color: '#FFE1D9',
        theme: 'trash',
        path: '/pages/index/trash/trash',
      },
      {
        naem: '设备管理',
        img: 'equipment.png',
        id: 'equipment',
        color: '#CEEFFE',
        theme: 'equipment',
        path: '/pages/index/equipment/equipment',
      },
    ]
    const inventory_list = [
      {
        naem: '库存统计',
        img: 'statistics.png',
        id: 'statistics',
        color: '#A5BDF9',
        theme: 'statistics',
        path: '/pages/index/statistics/statistics',
      },
      {
        naem: '生产登记',
        img: 'reg.png',
        id: 'reg',
        color: '#A5BDF9',
        theme: 'reg',
        path: '/pages/index/reg/reg',
      },
      {
        naem: '产废入库',
        img: 'put.png',
        id: 'put',
        color: '#9CE4C9',
        theme: 'put',
        path: '/pages/index/put/put',
      },
      {
        naem: '产废出库',
        img: 'out.png',
        id: 'out',
        color: '#FEE8B7',
        theme: 'out',
        path: '/pages/index/out/out',
      },
    ]
    /************************导出 *************************** */
    // 记得 return
    return { controls_list, inventory_list }
  },
  // TODO: 持久化
  {
    // 配置持久化
    persist: {
      // 调整为兼容多端的API
      storage: {
        setItem(key, value) {
          uni.setStorageSync(key, value)
        },
        getItem(key) {
          return uni.getStorageSync(key)
        },
      },
      paths: ['controls_list'],
    },
  },
)
